今天來增加關卡。
level = 1
max_level = 3
if not bricks:
if level == max_level:
screen.fill(white)
display_message("Congratulations!", black, -50)
draw_button("Restart", restart_button_rect, button_color, button_hover_color)
pygame.display.flip()
wait_for_button_click(restart_button_rect)
level = 1
reset_ball_and_paddle()
create_bricks()
else:
screen.fill(white)
display_message(f"Level {level} Complete!", black, -50)
draw_button("Next", next_button_rect, button_color, button_hover_color)
draw_button("Restart", restart_button_rect, button_color, button_hover_color)
pygame.display.flip()
wait_for_button_click(next_button_rect)
level += 1
ball_speed_x *= 1.2
ball_speed_y *= 1.2
reset_ball_and_paddle()
create_bricks()
next_button_rect = pygame.Rect(screen_width // 2 - 100, screen_height // 2 + 100, 200,100)
我自己有嚐試玩玩看,不小心把速度變數提太高,不斷在第一關重新開始,趕緊把數值調慢一點,果真讓我過了。沒想到調整數值差點把自己玩沒了。
那今天就先這樣。